﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using BesAsm.ModelData.Data;
using BesAsm.ModelData.Entities;
using BesAsm.ModelData.Services;
using BesAsm.ModelData.Data.Bases;
using BesAsm.ModelData.Data.GenericClient;

namespace BesAsm.ModelData.Gis
{
  /// <summary>
  /// Provides model data access and services
  /// </summary>
  public static class ModelProviderInitializer
  {
    /// <summary>
    /// Sets up the model data provider
    /// </summary>
    /// <param name="modelPath">Path and filename of model geodatabase</param>
    public static void InitializeModelProvider(string modelPath)
    {
      NetTiersProvider provider = new GenericNetTiersProvider();
      NameValueCollection config = new NameValueCollection();
      config.Add("useStoredProcedure", "false");
      config.Add("connectionString", 
        String.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};User Id=admin;Password=;",
          modelPath));
      config.Add("connectionStringName", "netTiersConnectionString");
      config.Add("providerInvariantName", "System.Data.OleDb");
      config.Add("useEntityFactory", "true");
      config.Add("enableEntityTracking", "false");
      config.Add("enableMethodAuthorization", "false");
      provider.Initialize("GenericNetTiersProvider", config);
      DataRepository.LoadProvider(provider, true);
     }
  }
}
